package com.bayair.doctor.ui.personal;

import android.content.Intent;
import android.os.Bundle;

import com.bayair.doctor.App;
import com.bayair.doctor.R;
import com.bayair.doctor.base.component.BaseActivity;
import com.bayair.doctor.biz.im_helper.IMHelper;
import com.bayair.doctor.ui.chat.ChatActivity;
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo;
import butterknife.BindView;

public class PersonalActivity extends BaseActivity {

    public static void actionStart(ChatInfo chatInfo) {
        Intent intent = new Intent(App.getContext(), PersonalActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(PERSONAL_CONTENT, chatInfo);
        App.getContext().startActivity(intent);
    }

    private static final String PERSONAL_CONTENT = "personal_content";

    @BindView(R.id.personal_layout)
    PersonalLayout layout;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_personal;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        Object chatInfo = getIntent().getSerializableExtra(PERSONAL_CONTENT);
        layout.initData(chatInfo);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setListener() {
        layout.setOnButtonClickListener(info -> {
            ChatInfo chatInfo = IMHelper.getInstance().contactToChat(info);
            ChatActivity.actionStart(chatInfo);
        });
    }
}
